
try:
    from cdar.models.Shallow_Water_2D.ShallowWater2DModel import ShallowWaterModelClass as model
except:
    raise ImportError('The model library cannot be found!')
    
try:
    from cdar.utilities import namelist_read as nml
except:
    raise ImportError('The nml library cannot be found!')
    
try:
    import ESMF
except:
    raise ImportError('The ESMP library cannot be found!')
    
    
DataFilePath='./data'  # Path to store or read FG, B and OBS

# Read in parameters for model configurations
params = nml.namelist_read(DataFilePath)

# start up ESMF
# this call is not necessary unless you want to to override the
# default options:
#  LogKind = NONE
#  debug = False
manager = ESMF.Manager(logkind=ESMF.LogKind.MULTI, debug=True)

# inquire for rank and proc from ESMF Virtual Machine
localPet = manager.local_pet
petCount = manager.pet_count
print "localPet = %d and petCount = %d " % (localPet, petCount)

# opening remarks
if localPet == 0:
    print "Welcome to the Model Tangent Linear and Adjoint Testing!"

# Set up the model    
domain = model(params)  

# Redefine the history output interval
domain.history_interval=60
domain.model_output_history()
"""

from cdar.models.Lorenz_63.Lorenz63 import Lorenz63ModelClass as model

domain = model(0,4,1000,time_diff_choice='leapfrog',x_noise=1,y_noise=1,z_noise=1)
"""

# Print domain info 
if localPet == 0:
    print domain
        
# Tangent Linear Check   
domain.model_tl_check ()
    
# Adjoint Check   
domain.model_ad_check ()
